package com.ruoyi.deepSeek;

import org.springframework.stereotype.Service;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

import java.io.IOException;
import java.io.OutputStream;

@Service
public class DeepSeekApiService {

    // 发送聊天消息，支持流式传输
    public SseEmitter sendChatMessage(String user, String query, String conversationId, String responseMode, Long classId) {
        // 调用 HttpClient 中封装了 OkHttp 请求的 SSE 方法，构造请求体等逻辑均保留
        return HttpClient.postChatMessageStream(user, query, conversationId, responseMode, classId);
    }
//    public void sendChatMessage(String user, String query, String conversationId, String responseMode, OutputStream outputStream) throws IOException {
//        // 调用 HttpClient 的方法，传递 OutputStream
//        HttpClient.postChatMessageStream(user, query, conversationId, responseMode, outputStream);
//    }

    // 上传文件，调用 HttpClient 上传文件的方法
    public String uploadImage(String user, String filePath) throws IOException {
        return HttpClient.uploadFile(user, filePath);
    }

    // 获取历史消息
    public String getMessages(String user, String conversationId, String firstId, int limit) throws IOException {
        return HttpClient.getMessages(user, conversationId, firstId, limit);
    }

    // 获取会话列表
    public String getConversations(String user, String lastId, int limit) throws IOException {
        return HttpClient.getConversations(user, lastId, limit);
    }

    // 删除会话
    public String deleteConversation(String conversationId, String user) throws IOException {
        return HttpClient.deleteConversation(conversationId, user);
    }

    // 会话重命名
    public String renameConversation(String conversationId, String user, String newName, boolean autoGenerate) throws IOException {
        return HttpClient.renameConversation(conversationId, user, newName, autoGenerate);
    }

    // 语音转文字
    public String audioToText(String user, String filePath) throws IOException {
        return HttpClient.audioToText(user, filePath);
    }

    // 文字转语音
    public String textToAudio(String user, String text) throws IOException {
        return HttpClient.textToAudio(user, text);
    }
}
